# Contributor: Simon Frankenberger <simon-alpine@fraho.eu>
# Maintainer: Simon Frankenberger <simon-alpine@fraho.eu>
pkgname=java-libsignal-client
pkgver=0.45.0
pkgrel=0
pkgdesc="libsignal-client contains platform-agnostic APIs useful for Signal client apps"
url="https://github.com/signalapp/libsignal"
# java >= 11 not available on 32 bit archs
# s390x: build error in boringssl ("Unknown target CPU")
# ppc64le: build error in boringssl ("Unknown target CPU")
# riscv64: build error in boringssl ("Unknown target CPU")
arch="all !armhf !armv7 !x86 !ppc64le !s390x !riscv64"
license="AGPL-3.0-or-later"
depends="java-jre-headless"
makedepends="bash cargo clang-dev cmake openjdk17-jdk protoc rust zip"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/signalapp/libsignal/archive/v$pkgver.tar.gz
	upgrade-gradle-fix-sigsegv-aarch64.patch
	"
install="$pkgname.post-install $pkgname.post-upgrade"
builddir="$srcdir/libsignal-$pkgver"
# tests succeed, but gradle aborts with exit value 134. have to further investigate later
options="!check"

build() {
	cd "$builddir"/java
	./gradlew --no-daemon -PskipAndroid :client:jar
}

check() {
	cd "$builddir"/java
	./gradlew --no-daemon -PskipAndroid :client:test
}

package() {
	install -D -m644 "$builddir"/java/client/build/libs/libsignal-client-$pkgver.jar \
		-t "$pkgdir"/usr/share/java/libsignal-client
	install -D -m755 "$builddir"/target/release/libsignal_jni.so \
		-t "$pkgdir"/usr/lib
	zip -d "$pkgdir"/usr/share/java/libsignal-client/libsignal-client-$pkgver.jar \
		libsignal_jni.so
}

sha512sums="
70f2cb7d05e019235cd044c401bcf072a934fdfea4a161ef5be988d2e3932ba5233110b4b06525e6f33ea9cad036def442e70adad15eab883903d9246969896e  java-libsignal-client-0.45.0.tar.gz
acfa6c1595691885b45785b8cb274fef24fea512ba86a06c99da5e278fb03b23866de079a4a5b43d593071d103baeb7e720d33797185a3c4f4a29004a7ce3d78  upgrade-gradle-fix-sigsegv-aarch64.patch
"
